package com.example.nightmeel.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class TimeLineDbHelper extends SQLiteOpenHelper {
    //DB名
    static final String DATABASE_NAME = "timelinetable.db";
    static final int DATABASE_VERSION = 2;
    
    //SQL文
    private static final String CREATE_TIMELINE_TABLE_SQL = "create table timelinetable "
            + "(rowid integer primary key autoincrement, "
            + "user_id integer, "
            + "user_name text not null, "
            + "image text not null, "
            + "image_size integer default 0, "
            + "geotag text, "
            + "message text, "
            + "category integer default 0, "
            + "advertisement_flg integer default 0, "
            + "good_cnt integer default 0, "
            + "season integer default 0, "
            + "daytime integer default 0, "
            + "lastupdate text not null, "
            + "user_icon text not null)";
    private static final String DROP_TIMELINE_TABLE_SQL = "drop table if exists timelinetable";

    //インストラクタ
    public TimeLineDbHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    //テーブル作成
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_TIMELINE_TABLE_SQL);
    }

    //テーブル更新
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL(DROP_TIMELINE_TABLE_SQL);
        onCreate(db);
    }
}
